import json
from common.baseApi import BaseAPI


class Goods(BaseAPI):

    # 发布商品
    def create_goods(self, headers, in_data):
        resp_data = self.requests_send(headers=headers, data=json.dumps(in_data))
        return resp_data

    # 商品列表
    def goods_list(self, headers, in_data):
        resp_data = self.requests_send(headers=headers, data=in_data)
        return resp_data


if __name__ == '__main__':
    headers = {
        'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJzZWxmT3BlcmF0ZWQiOjEsInN1YiI6InVzZXIiLCJmb3VuZGVyIjoxLCJyb2xlcyI6WyJCVVlFUiIsIlNFTExFUiIsIkNMRVJLIiwiU0VMTEVSX1NVUEVSX1NFTExFUiJdLCJzZWxsZXJOYW1lIjoi5ZOB54mM5oqY5omjIiwiY2xlcmtJZCI6bnVsbCwiaXNFbnRlcnByaXNlQWRtaW4iOjAsInV1aWQiOiJhYjMzYWMxMC02YzRjLTExZjAtOTg2OS1kZDg1YzZmN2FlYjIiLCJ1aWQiOjE4NjEyNDQ4MzU2NDY2ODUxODYsInNlbGxlcklkIjoxODYxMzEyMzgxMTU0NjE1Mjk4LCJlbnRlcnByaXNlSWQiOm51bGwsInNob3BUeXBlIjoiU1VQUExJRVIiLCJjbGVya05hbWUiOiJneXMxIiwiZXhwIjoyNTE2NjcyOTg1LCJlbnRlcnByaXNlTmFtZSI6bnVsbCwidXNlcm5hbWUiOiJneXMxIn0.COBKue9FfMMFUyn9N-BFTZ-cDlyKrkf4qD0lHj-nd6ZOcJ2YtZaMfGVGBPW0rrOQrtm1uH-o4Mp9OnF-e8Hhlg',
        'Content-Type': 'application/json'
    }
    payload = {
        "brand_id": "1953658126917820418",
        "category_id": "163",
        "category_name": "",
        "goods_name": "AutoTestGoods001",
        "sn": "20250814000002",
        "price": "",
        "supplier_price": "15",
        "mktprice": "",
        "cost": "30",
        "weight": "1",
        "goods_gallery_list": [
            {
                "original": "https://shuogeshi-1255375710.cos.ap-beijing.myqcloud.com/javashop6173c31a-e4a9-41d6-a286-9c21ec8360d6.jpg",
                "img_id": -1,
                "sort": 0
            }
        ],
        "goods_video": "",
        "free_freight": 1,
        "need_packing": "NO",
        "packing_price": "",
        "market_enable": 1,
        "template_id": "0",
        "shop_cat_id": 0,
        "meta_description": "",
        "meta_keywords": "",
        "page_title": "",
        "goods_params_list": [
            {
                "id": None,
                "goods_id": None,
                "param_id": "230",
                "param_name": "生产许可证编号",
                "param_value": "",
                "param_type": 1,
                "options": "",
                "required": 0,
                "group_id": "50",
                "is_index": 0,
                "option_list": [
                    ""
                ]
            },
            {
                "id": None,
                "goods_id": None,
                "param_id": "248",
                "param_name": "品牌",
                "param_value": "",
                "param_type": 1,
                "options": "",
                "required": 0,
                "group_id": "50",
                "is_index": 0,
                "option_list": [
                    ""
                ]
            },
            {
                "id": None,
                "goods_id": None,
                "param_id": "249",
                "param_name": "型号",
                "param_value": "",
                "param_type": 1,
                "options": "",
                "required": 0,
                "group_id": "50",
                "is_index": 0,
                "option_list": [
                    ""
                ]
            }
        ],
        "intro": "<p>商品详情#</p>",
        "goods_type": "NORMAL",
        "expired_date": "",
        "point_disable": 0,
        "exchange_point": "",
        "select_labels": [
            "214"
        ],
        "goods_store": "故事内容测试#"
    }
    headers = {
        'Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJzZWxmT3BlcmF0ZWQiOjEsInN1YiI6InVzZXIiLCJmb3VuZGVyIjoxLCJyb2xlcyI6WyJCVVlFUiIsIlNFTExFUiIsIkNMRVJLIiwiU0VMTEVSX1NVUEVSX1NFTExFUiJdLCJzZWxsZXJOYW1lIjoi5ZOB54mM5oqY5omjIiwiY2xlcmtJZCI6bnVsbCwiaXNFbnRlcnByaXNlQWRtaW4iOjAsInV1aWQiOiJhYjMzYWMxMC02YzRjLTExZjAtOTg2OS1kZDg1YzZmN2FlYjIiLCJ1aWQiOjE4NjEyNDQ4MzU2NDY2ODUxODYsInNlbGxlcklkIjoxODYxMzEyMzgxMTU0NjE1Mjk4LCJlbnRlcnByaXNlSWQiOm51bGwsInNob3BUeXBlIjoiU1VQUExJRVIiLCJjbGVya05hbWUiOiJneXMxIiwiZXhwIjoyNTE2NjcyOTg1LCJlbnRlcnByaXNlTmFtZSI6bnVsbCwidXNlcm5hbWUiOiJneXMxIn0.COBKue9FfMMFUyn9N-BFTZ-cDlyKrkf4qD0lHj-nd6ZOcJ2YtZaMfGVGBPW0rrOQrtm1uH-o4Mp9OnF-e8Hhlg',
        'Content-Type': 'application/json'
    }

    res = Goods(env='test', host_type='sgs_url').create_goods(headers, payload)
    print(res)
